<?php
namespace App\Listener;

use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Event\Annotation\Listener;

/**
 * @Listener 
 */
class UserPayRefundListener implements ListenerInterface
{
    public function listen(): array
    {
        return [
            \App\Event\UserPay\StatusNoEvent::class,
        ];
    }
    
    // 退款
    public function process($event)
    {
        $user = $event->user;
        
        // 退优惠
        if($event->pay->discount > 0)
        {
            $user->moneyDiscountAdd($event->pay->discount, '充值关闭');
        }
        
        // 退补贴
        if($event->pay->discount > 0)
        {
            $user->moneyFullAdd($event->pay->full, '充值关闭');
        }
    }
}